package main

import (
	"crypto/sha256"
	"fmt"
)

func main() {
	fmt.Printf("%d \n", compareSha256("x", "X"))
}

func compareSha256(str1 string, str2 string) int {
	a := sha256.Sum256([]byte(str1))
	b := sha256.Sum256([]byte(str2))
	num := 0
	// 循环字节数组
	for i := 0; i < len(a); i++ {
		for m := 0; m <= 7; m++ { // 对比字节是否相同
			if (a[i] & (1 << m)) != (b[i] & (1 << m)) {
				num++
			}
		}
	}
	return num
}
